﻿@model QLMB.ViewModels.FlightItem

@{
    ViewBag.Title = "EditFlight";
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
}

<script language = "javascript" type ="text/javascript">
    $(document).ready(function () {
        var now = new Date();
        var str_datevalue = $("#NgayDi").val();
        var datevalue = new Date(str_datevalue);
        var offset = datevalue.getTime() - now.getTime();
        var totalday = Math.round(offset / 1000 / 60 / 60 / 24);
        var max = totalday + 3;
        $('.date').datepicker({ dateFormat: "mm/dd/yy", maxDate: '+' + max + 'd', minDate: '+' + totalday + 'd' });
        var trangthaicb = $("#TrangThaiCB").val();
        var MaMB = $("#MaMB").val();

        $("#TrangThaiCB").change(function () {
            if (($(this).val() == trangthaicb) && ($("#MaMB").val() ==MaMB))
                $("input[type=submit]").attr("disabled", "disabled");
            else $("input[type=submit]").removeAttr("disabled", "disabled");
        });
        $("#MaMB").change(function () {
            if (($(this).val() == MaMB) && ($("#TrangThaiCB").val() = trangthaicb))
                $("input[type=submit]").attr("disabled", "disabled");
            else $("input[type=submit]").removeAttr("disabled", "disabled");
        });
        $("#NgayDi").change(function () {
            $("input[type=submit]").removeAttr("disabled", "disabled");
        });
    });
</script>



<h2>Edit Flight</h2>
@{
    if (Model.errmes != null)
    {
        <h3>@Model.errmes</h3>
    }
}

@using (@Html.BeginForm())
{
    <div id ="flightinfo">
        <table>
        <tr>
            <th>Mã chuyến bay</th>
            <th>Thông tin đường bay</th>
            <th>Thông tin chuyến bay</th>
            <th>Thời gian đi</th>
            <th>Thời gian đến</th>
        </tr>
        <tr>
            <td><b>@Html.Label(Model.MaCB)</b></td> 
                <td><b>@Html.LabelFor(x => x.MaDB): </b> 
                @Html.Label(Model.MaDB) <br />
                <b>@Html.LabelFor(x => x.SbDi):</b>
                @Html.Label(Model.SbDi) <br />
                <b>@Html.LabelFor(x => x.SbDen):</b>
                @Html.Label(Model.SbDen) <br />
                <b>@Html.LabelFor(x => x.HangKhaiThac):</b>
                @Html.Label(Model.HangKhaiThac) <br />
            </td>
        <td>
            <b>@Html.LabelFor(x => x.MaMB):</b>
            @{if (Model.MaMB != null)
              {
                          @Html.DropDownListFor(x => x.MaMB, new SelectList(Model.DsMB, "value", "text"));      
              }
                    }
            <br />
            <b>@Html.LabelFor(x => x.ThoiGianBay):</b>
            @Html.Label(Model.ThoiGianBay.ToString())   phút<br />
            <b>@Html.LabelFor(x => x.TrangThaiCB):</b> <br />
            @{
                if (Model.TrangThaiCB.CompareTo("Đặt vé") == 0)
                {
                        @Html.DropDownListFor(x => x.TrangThaiCB, new SelectList(new[]
                                                                {
                                                                    new{val = "Đặt vé", Text = "Đặt vé"},
                                                                    new{val = "Sẵn sàng bay", Text = "Sẵn sàng bay"},
                                                                }, "val", "text"))
                                                                <br />
                }
                else
                {
                @Html.DropDownListFor(x => x.TrangThaiCB, new SelectList(new[]
                                                                {
                                                                    new{val = "Sẵn sàng bay", Text = "Sẵn sàng bay"},
                                                                    new{val = "Đặt vé", Text = "Đặt vé"},
                                                                }, "val", "text"))
                                                                <br />
                }
            }
            
            <b>@Html.LabelFor(x => x.TongSoGheDaDat):</b>
            @Html.Label(Model.TongSoGheDaDat.ToString()) <br />
            @{
                if(Model.KhuyenMai !=null)
                {
                    @Html.LabelFor(x => x.KhuyenMai) <br />
                    @Html.EditorFor(x=>x.KhuyenMai)   <br />
                    @Html.ValidationMessageFor(x=>x.KhuyenMai) 
                }
            }
            <b>@Html.LabelFor(x => x.NgayKhoiTao):</b><br />
            @Html.Label(Model.NgayKhoiTao.ToString())<br />
            <b> Danh sách hành khách</b>
        </td> 
        <td>
        <b>@Html.Label("Ngày bay"):</b>
        @Html.EditorFor(x => x.NgayDi)<br />
        @Html.ValidationMessageFor(x => x.NgayDi.Hour)<br />
        <b>@Html.Label("Thời gian xuất phát"):</b> <br />
        <b>@Html.Label("Giờ")</b>
        @Html.EditorFor(x=>x.Gio) <br />
        @Html.ValidationMessageFor(x => x.Gio)<br />
        <b>@Html.Label("Phút")</b>
        @Html.EditorFor(x => x.Phut) <br />
        @Html.ValidationMessageFor(x => x.Phut)<br />
        </td>
        <td>@Html.Label(Model.NgayDen.ToString())<br />
        </td>
        </tr>
    </table></div>
    <div id = "lydo"> 
    <b>Lý do cập nhật:</b> @Html.TextAreaFor(x=>x.LyDoCapNhat) <br />
    @Html.ValidationMessageFor(x=>x.LyDoCapNhat)
    </div>
    <input type =submit Value = "Cập nhật" disabled="disabled" />
}
   


